Skip to content

fix(aggregator): serve self-unregistering /sw.js kill switch - #1434

Merged
dezren39 merged 1 commit into
mainfrom
fix/sw-kill-switch
Oct 27, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/sw-kill-switch

Conversation

@dezren39

@dezren39 dezren39 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Why

Until 2026-10-27 the dashboard origin (https://amd-6.raptor-pumpkinseed.ts.net, the laptop tailnet-serve clean address) fronted the opencode web app. Browsers that visited it then -- Drew's included -- registered opencode's Workbox service worker for that origin. The origin now serves the dashboard, but the stranded worker keeps answering from its precache, so those browsers see the opencode shell instead of the dashboard. The dashboard origin returned 404 for /sw.js, so the registration never updated.

What

GET /sw.js on the aggregator now returns a tiny, dependency-free service worker that calls skipWaiting on install and, on activate, unregisters itself and navigates controlled window clients back to their current URL. On the browser's next service-worker update check it installs, removes the registration, and open tabs reload into the dashboard -- no user action needed. Fresh browsers that ever fetch it are unaffected (it removes itself immediately).

  • Content-Type: text/javascript, Cache-Control: no-cache (so update checks always revalidate).
  • One route + one script constant in src/server.ts, following the existing handler/helper patterns.
  • Boot test added asserting status, content type, cache header, and the unregister behavior.

Verification (on the laptop)

  • bun test: 273 pass, 0 fail (suite incl. the new boot test).
  • bun run typecheck: clean.

Context: code#1363 (serve remap). The opencode origin (:4096) keeps serving its own real /sw.js -- untouched.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

The dashboard origin fronted the opencode web app until 2026-10-27;
browsers that visited it then still hold opencode's Workbox service
worker, which serves the opencode shell from cache. A tiny valid
worker at /sw.js unregisters itself on activate and reloads open
tabs, so stranded browsers heal on their next update check.
@dezren39
dezren39 requested a review from a team as a code owner October 27, 2026 15:31
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe8ed611-2473-430a-bc0c-2c8c9acc5cf0
Commits

Reviewing files that changed from the base of the PR and between 73190c7 and 9d870a2.

Files selected for processing: 2
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/test/boot.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T15:34:22.160112Z 9d870a2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 95cd41f into main Oct 27, 2026
4 checks passed
@dezren39
dezren39 deleted the fix/sw-kill-switch branch October 27, 2026 15:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d870a21b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +201 to +204
self.addEventListener('activate', async () => {
try { await self.registration.unregister(); } catch {}
const cs = await self.clients.matchAll({ type: 'window' });
for (const c of cs) { try { c.navigate(c.url); } catch {} }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Extend the activation event through cleanup and navigation

When this replacement worker activates for a browser displaying the stale opencode shell, the async listener's returned promise does not extend the activation event. The browser can therefore terminate the worker while unregister() or matchAll() is pending, leaving the open tabs unreloaded; the service-worker lifetime specification explicitly permits termination when there is no event to handle. Pass the entire cleanup operation to the activation event's waitUntil() and await the navigation promises as well, so the kill switch keeps the worker alive until its recovery work completes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant